/**
 * 文件名：TaskBean.java
 *
 * 版本信息：
 * 日期：2013-3-19
 * Copyright 足下 Corporation 2013 
 * 版权所有
 *
 */
package com.hugedata.cdn.service.task.bean;

import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;

import com.hugedata.cdn.service.util.TaskFieldChooseFilter;

/**
 * 
 * 项目名称：xiaomifeng 类名称：TaskBean 类描述： 创建人：zhaoaihua 创建时间：2013-3-19 下午4:16:57
 * 修改备注：
 * 
 * @version
 * 
 */
public class ToolTaskBean {

    // 任务id
    private String           taskID;

    // 用户ID
    private String           userID;

    // 任务名称
    private String           taskName;

    private String           taskHost;

    private String           taskPort;

    private int              taskType;

    private int              urlType = 2;

    private String           tasks;

    private ToolTaskInfoHttp advancedOptions;

    public String getTaskID() {
        return taskID;
    }

    public void setTaskID(String taskID) {
        this.taskID = taskID;
    }

    public String getUserID() {
        return userID;
    }

    public void setUserID(String userID) {
        this.userID = userID;
    }

    public String getTaskName() {
        return taskName;
    }

    public void setTaskName(String taskName) {
        this.taskName = taskName;
    }

    public String getTaskHost() {
        return taskHost;
    }

    public void setTaskHost(String taskHost) {
        this.taskHost = taskHost;
    }

    public String getTaskPort() {
        return taskPort;
    }

    public void setTaskPort(String taskPort) {
        this.taskPort = taskPort;
    }

    public int getTaskType() {
        return taskType;
    }

    public void setTaskType(int taskType) {
        this.taskType = taskType;
    }

    public String toTaskJson(String[] fields) {

        // json属性选择
        // String[] fields = {
        // "taskID", "taskType", "taskHost", "taskPort", "taskInterval" };

        JsonConfig config = new JsonConfig();
        config.setJsonPropertyFilter(new TaskFieldChooseFilter(fields));

        return JSONObject.fromObject(this, config).toString();

    }

    public boolean equals(ToolTaskBean anObject) {
        if (null == anObject) {
            return false;
        }

        return anObject.taskID.equalsIgnoreCase(this.taskID);
    }

    public int getUrlType() {
        return urlType;
    }

    public void setUrlType(int urlType) {
        this.urlType = urlType;
    }

    public String getTasks() {
        return tasks;
    }

    public void setTasks(String tasks) {
        this.tasks = tasks;
    }

    public ToolTaskInfoHttp getAdvancedOptions() {
        return advancedOptions;
    }

    public void setAdvancedOptions(ToolTaskInfoHttp advancedOptions) {
        this.advancedOptions = advancedOptions;
    }

}
